package com.mooral.web.action.merchant;

import java.sql.ResultSet;
import java.util.Collection;
import java.util.Vector;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;

import com.mooral.bean.Beans;
import com.mooral.bean.Merchant;
import com.mooral.context.Context;
import com.mooral.dataAccess.DataAccessConnection;
import com.mooral.web.action.MooralAction;

public class SearchAction extends MooralAction {

	public ActionForward perform(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			Context context) throws Exception {

		
		DynaActionForm dform = (DynaActionForm) form;
		String letter = (String) dform.get("letter");

		Beans beans = new Beans();
		beans.populate(new Merchant(), "SELECT * FROM merchants WHERE name REGEXP '^[" + letter + "]+'");


		request.setAttribute("merchants", beans);



	    request.setAttribute("headerTitle", "Specific Retailer");
	    request.setAttribute("metaDescription", "Search for a specific merchant at voucheap.com");
	    request.setAttribute("metaKeywords", "Retailers Merchants");
	    
		
		return mapping.findForward(ACTION_SUCCESS);
	}

}